<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="选择用户" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doGo(pageIndex){
		var searchKey=encodeURIComponent("${searchKey}");
		window.location="/system/UserListForSelect.ihtm?type=${type}&include_admin=${includeAdmin}&search_key="+searchKey+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function doSelect(index){
		var arr=new Array();
		var ob_arr = document.getElementsByName("query_checkbox");
		if ( ob_arr.length>=index ){
			var a=new Array();
			a[0]=ob_arr[index-1].value;
			a[1]=ob_arr[index-1].getAttribute("user_name");
			a[2]=ob_arr[index-1].getAttribute("staffer_id");
			a[3]=ob_arr[index-1].getAttribute("staffer_name");
			
			arr[0]=a;
			parent.popRetVal=arr;
		}
		parent.ClosePop();
	}
	function doMutiSelect(){
		var arr=new Array();
		var ob_arr = document.getElementsByName("query_checkbox");
		
		var a;
		var index=0;
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				a=new Array();
				a[0]=ob_arr[i].value;
				a[1]=ob_arr[i].getAttribute("user_name");
				a[2]=ob_arr[i].getAttribute("staffer_id");
				a[3]=ob_arr[i].getAttribute("staffer_name");
				arr[index]=a;
				index++;
			}
		}
		
		if(arr.length>0){
			parent.popRetVal=arr;
			parent.ClosePop();
		}else{
			ShowAlert('提示框','请选择用户',200,100);
		}
	}
	function DoubleClick(it){
		var arr=new Array();
		var ob_arr = document.getElementsByName("query_checkbox");
		if(ob_arr.length>=it.getAttribute("index")){
			var a=new Array();
			a[0]=ob_arr[it.getAttribute("index")-1].value;
			a[1]=ob_arr[it.getAttribute("index")-1].getAttribute("user_name");
			a[2]=ob_arr[it.getAttribute("index")-1].getAttribute("staffer_id");
			a[3]=ob_arr[it.getAttribute("index")-1].getAttribute("staffer_name");
				
			arr[0]=a;
			parent.popRetVal=arr;
		}
		parent.ClosePop();
	}
	function doSearch(){
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		window.location="/system/UserListForSelect.ihtm?type=${type}&include_admin=${includeAdmin}&search_key="+searchKey;
	}
	function doCancel(){
		parent.ClosePop();
	}
	function doInit(){
		Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doAll(obj){
		var ob_arr = document.getElementsByName("query_checkbox");
		for (i=0;i<ob_arr.length;i++){
			ob_arr[i].checked=obj.checked;
		}
	}
</script>
</head>
<body oncontextmenu="return false" onload="doInit();"  class="sheet">
<div class="sheet-main" style="width:570px">
  <div class="sheet-top">
    <div class="content">
      <h2>选择用户</h2>
	  <p>可以通过账户、姓名或者姓名拼音字头进行模糊查询，鼠标双击记录就可以选中单个记录</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="458">
          <tbody>
            <tr>
              <td  align="right">
	              <input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" style="width:100px" value="${searchKey}" title="以账户、姓名或者姓名拼音字头进行模糊查询">
	              <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();" title="以账户、姓名或者姓名拼音字头进行模糊查询">
			      <input type="button" class="buttom search-select" value=" 选 择 " onClick="doMutiSelect();">	              
			  </td>
            </tr>    
           </tbody>      
        </table>
      </div>
      <div class="table-list">
        <table width="100%">      
 					<tr >	
						<th width="14"><input type="checkbox" onClick="doAll(this);"></th>
						<th width="20%">登录账户</th>
						<th width="20%">部门</th>
						<th width="20%">姓名</th>
						<th width="30%">职位</th>
						<th width="10%">操作</th>
					</tr>
					<c:forEach var="item" items="${userList}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item[0]}" user_name="${item[1]}" staffer_id="${item[9]}" staffer_name="${item[2]}"></td>
						<td>${item[1]}</td>
						<td>${item[7]}</td>
						<td>${item[2]}</td>
						<td>${item[8]}</td>
						<td>
							<a href="javascript:doSelect('${i.index+1}');">选择</a>
						</td>
					</tr>
					</c:forEach>
				</table>
      </div>
    </div>
  </div>
</div>
</body>
</html>